package com.tom.de;


import org.springframework.context.annotation.Bean;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


/**
 * 自定义拦截器
 */
public class AuthorityInterceptor implements HandlerInterceptor {

    /**
     * 实例化
     * @return ipService
     */
    @Bean
    public IPService ipService(){
        return new IPService();
    }
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        System.out.println(" ----------------"+request.getRequestURI()+ "请求被拦截了----------------- ");
        ipService().record(request);
        return true;
    }
}


